<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>lwIP: src/core/inet_chksum.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">lwIP
   &#160;<span id="projectnumber">2.1.2</span>
   </div>
   <div id="projectbrief">Lightweight IP stack</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('inet__chksum_8c.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">inet_chksum.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &quot;<a class="el" href="opt_8h.html">lwip/opt.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="inet__chksum_8h.html">lwip/inet_chksum.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="def_8h.html">lwip/def.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="ip__addr_8h.html">lwip/ip_addr.h</a>&quot;</code><br />
<code>#include &lt;string.h&gt;</code><br />
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a102544bca5912c78649e25a45a7d0a88"><td class="memItemLeft" align="right" valign="top">u16_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="inet__chksum_8c.html#a102544bca5912c78649e25a45a7d0a88">ip6_chksum_pseudo</a> (struct <a class="el" href="structpbuf.html">pbuf</a> *p, u8_t proto, u16_t proto_len, const <a class="el" href="ip6__addr_8h.html#aaca9e796e93a355294c4954c08d01762">ip6_addr_t</a> *src, const <a class="el" href="ip6__addr_8h.html#aaca9e796e93a355294c4954c08d01762">ip6_addr_t</a> *dest)</td></tr>
<tr class="separator:a102544bca5912c78649e25a45a7d0a88"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae4218e08510fd92c9a699c4e5d9fc17b"><td class="memItemLeft" align="right" valign="top">u16_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="inet__chksum_8c.html#ae4218e08510fd92c9a699c4e5d9fc17b">ip6_chksum_pseudo_partial</a> (struct <a class="el" href="structpbuf.html">pbuf</a> *p, u8_t proto, u16_t proto_len, u16_t chksum_len, const <a class="el" href="ip6__addr_8h.html#aaca9e796e93a355294c4954c08d01762">ip6_addr_t</a> *src, const <a class="el" href="ip6__addr_8h.html#aaca9e796e93a355294c4954c08d01762">ip6_addr_t</a> *dest)</td></tr>
<tr class="separator:ae4218e08510fd92c9a699c4e5d9fc17b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab35967a50418358e194e8f80fdc3c865"><td class="memItemLeft" align="right" valign="top">u16_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="inet__chksum_8c.html#ab35967a50418358e194e8f80fdc3c865">inet_chksum_pbuf</a> (struct <a class="el" href="structpbuf.html">pbuf</a> *p)</td></tr>
<tr class="separator:ab35967a50418358e194e8f80fdc3c865"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Internet checksum functions.<br />
 These are some reference implementations of the checksum algorithm, with the aim of being simple, correct and fully portable. Checksumming is the first thing you would want to optimize for your platform. If you create your own version, link it in and in your cc.h put:</p>
<p>#define LWIP_CHKSUM your_checksum_routine</p>
<p>Or you can select from the implementations below by defining LWIP_CHKSUM_ALGORITHM to 1, 2 or 3. </p>
</div><h2 class="groupheader">Function Documentation</h2>
<a id="ab35967a50418358e194e8f80fdc3c865"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab35967a50418358e194e8f80fdc3c865">&#9670;&nbsp;</a></span>inet_chksum_pbuf()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">u16_t inet_chksum_pbuf </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="structpbuf.html">pbuf</a> *&#160;</td>
          <td class="paramname"><em>p</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Calculate a checksum over a chain of pbufs (without pseudo-header, much like inet_chksum only pbufs are used).</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">p</td><td>pbuf chain over that the checksum should be calculated </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>checksum (as u16_t) to be saved directly in the protocol header </dd></dl>

</div>
</div>
<a id="a102544bca5912c78649e25a45a7d0a88"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a102544bca5912c78649e25a45a7d0a88">&#9670;&nbsp;</a></span>ip6_chksum_pseudo()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">u16_t ip6_chksum_pseudo </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="structpbuf.html">pbuf</a> *&#160;</td>
          <td class="paramname"><em>p</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8_t&#160;</td>
          <td class="paramname"><em>proto</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u16_t&#160;</td>
          <td class="paramname"><em>proto_len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="ip6__addr_8h.html#aaca9e796e93a355294c4954c08d01762">ip6_addr_t</a> *&#160;</td>
          <td class="paramname"><em>src</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="ip6__addr_8h.html#aaca9e796e93a355294c4954c08d01762">ip6_addr_t</a> *&#160;</td>
          <td class="paramname"><em>dest</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Calculates the checksum with IPv6 pseudo header used by TCP and UDP for a pbuf chain. IPv6 addresses are expected to be in network byte order.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">p</td><td>chain of pbufs over that a checksum should be calculated (ip data part) </td></tr>
    <tr><td class="paramname">proto</td><td>ipv6 protocol/next header (used for checksum of pseudo header) </td></tr>
    <tr><td class="paramname">proto_len</td><td>length of the ipv6 payload (used for checksum of pseudo header) </td></tr>
    <tr><td class="paramname">src</td><td>source ipv6 address (used for checksum of pseudo header) </td></tr>
    <tr><td class="paramname">dest</td><td>destination ipv6 address (used for checksum of pseudo header) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>checksum (as u16_t) to be saved directly in the protocol header </dd></dl>

</div>
</div>
<a id="ae4218e08510fd92c9a699c4e5d9fc17b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae4218e08510fd92c9a699c4e5d9fc17b">&#9670;&nbsp;</a></span>ip6_chksum_pseudo_partial()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">u16_t ip6_chksum_pseudo_partial </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="structpbuf.html">pbuf</a> *&#160;</td>
          <td class="paramname"><em>p</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8_t&#160;</td>
          <td class="paramname"><em>proto</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u16_t&#160;</td>
          <td class="paramname"><em>proto_len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u16_t&#160;</td>
          <td class="paramname"><em>chksum_len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="ip6__addr_8h.html#aaca9e796e93a355294c4954c08d01762">ip6_addr_t</a> *&#160;</td>
          <td class="paramname"><em>src</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="ip6__addr_8h.html#aaca9e796e93a355294c4954c08d01762">ip6_addr_t</a> *&#160;</td>
          <td class="paramname"><em>dest</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Calculates the checksum with IPv6 pseudo header used by TCP and UDP for a pbuf chain. IPv6 addresses are expected to be in network byte order. Will only compute for a portion of the payload.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">p</td><td>chain of pbufs over that a checksum should be calculated (ip data part) </td></tr>
    <tr><td class="paramname">proto</td><td>ipv6 protocol/next header (used for checksum of pseudo header) </td></tr>
    <tr><td class="paramname">proto_len</td><td>length of the ipv6 payload (used for checksum of pseudo header) </td></tr>
    <tr><td class="paramname">chksum_len</td><td>number of payload bytes used to compute chksum </td></tr>
    <tr><td class="paramname">src</td><td>source ipv6 address (used for checksum of pseudo header) </td></tr>
    <tr><td class="paramname">dest</td><td>destination ipv6 address (used for checksum of pseudo header) </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>checksum (as u16_t) to be saved directly in the protocol header </dd></dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_aebb8dcc11953d78e620bbef0b9e2183.html">core</a></li><li class="navelem"><a class="el" href="inet__chksum_8c.html">inet_chksum.c</a></li>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
</body>
</html>
